#!/bin/bash
build_version="5.0.1"
centos_version="7"

while getopts "v:n:" optname
do
    case "$optname" in
    "v")
        centos_version="$OPTARG"
        echo "centos Version $OPTARG"
        ;;
    "n")
        build_version="$OPTARG"
        echo "build version $OPTARG"
        ;;
    *)
        # Should not occur
        echo "Unknown error while processing options"
        ;;
    esac
    echo "OPTIND is now $OPTIND"
done

rpm_version=`git rev-list HEAD | wc -l`
scp /opt/rpmbuild/RPMS/x86_64/vrcm-${build_version}-${rpm_version}.el${centos_version}.x86_64.rpm root@172.16.27.140:/home/public/centos${centos_version}/
scp /opt/rpmbuild/RPMS/x86_64/vrcm-${build_version}-${rpm_version}.el${centos_version}.x86_64.rpm root@159.138.22.154:/var/www/html/centos${centos_version}/
ssh root@172.16.27.140 "/usr/bin/createrepo --update /home/public/centos${centos_version}/"
ssh root@159.138.22.154 "/usr/bin/createrepo --update /var/www/html/centos${centos_version}/"
